/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Carito
 */
@Entity
@Table(name = "REPETICION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Repeticion.findAll", query = "SELECT r FROM Repeticion r"),
    @NamedQuery(name = "Repeticion.findByIdrepeticion", query = "SELECT r FROM Repeticion r WHERE r.idrepeticion = :idrepeticion"),
    @NamedQuery(name = "Repeticion.findByInicio", query = "SELECT r FROM Repeticion r WHERE r.inicio = :inicio"),
    @NamedQuery(name = "Repeticion.findByFin", query = "SELECT r FROM Repeticion r WHERE r.fin = :fin"),
    @NamedQuery(name = "Repeticion.findByIdcita", query = "SELECT r FROM Repeticion r WHERE r.repeticionPK.idcita = :idcita"),
    @NamedQuery(name = "Repeticion.findByIdusuario", query = "SELECT r FROM Repeticion r WHERE r.repeticionPK.idusuario = :idusuario"),
    @NamedQuery(name = "Repeticion.findByIdempresa", query = "SELECT r FROM Repeticion r WHERE r.repeticionPK.idempresa = :idempresa")})
public class Repeticion implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RepeticionPK repeticionPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "IDREPETICION")
    private BigInteger idrepeticion;
    @Column(name = "INICIO")
    @Temporal(TemporalType.DATE)
    private Date inicio;
    @Column(name = "FIN")
    @Temporal(TemporalType.DATE)
    private Date fin;
    @JoinColumns({
        @JoinColumn(name = "IDCITA", referencedColumnName = "IDCITA", insertable = false, updatable = false),
        @JoinColumn(name = "IDUSUARIO", referencedColumnName = "IDUSUARIO", insertable = false, updatable = false),
        @JoinColumn(name = "IDEMPRESA", referencedColumnName = "IDEMPRESA", insertable = false, updatable = false)})
    @OneToOne(optional = false, fetch = FetchType.EAGER)
    private Cita cita;

    public Repeticion() {
    }

    public Repeticion(RepeticionPK repeticionPK) {
        this.repeticionPK = repeticionPK;
    }

    public Repeticion(RepeticionPK repeticionPK, BigInteger idrepeticion) {
        this.repeticionPK = repeticionPK;
        this.idrepeticion = idrepeticion;
    }

    public Repeticion(BigInteger idcita, BigInteger idusuario, BigInteger idempresa) {
        this.repeticionPK = new RepeticionPK(idcita, idusuario, idempresa);
    }

    @XmlElement
    public RepeticionPK getRepeticionPK() {
        return repeticionPK;
    }

    public void setRepeticionPK(RepeticionPK repeticionPK) {
        this.repeticionPK = repeticionPK;
    }

    @XmlElement
    public BigInteger getIdrepeticion() {
        return idrepeticion;
    }

    public void setIdrepeticion(BigInteger idrepeticion) {
        this.idrepeticion = idrepeticion;
    }

    @XmlElement
    public Date getInicio() {
        return inicio;
    }

    public void setInicio(Date inicio) {
        this.inicio = inicio;
    }

    @XmlElement
    public Date getFin() {
        return fin;
    }

    public void setFin(Date fin) {
        this.fin = fin;
    }

    @XmlElement
    public Cita getCita() {
        return cita;
    }

    public void setCita(Cita cita) {
        this.cita = cita;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (repeticionPK != null ? repeticionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Repeticion)) {
            return false;
        }
        Repeticion other = (Repeticion) object;
        if ((this.repeticionPK == null && other.repeticionPK != null) || (this.repeticionPK != null && !this.repeticionPK.equals(other.repeticionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Repeticion[ repeticionPK=" + repeticionPK + " ]";
    }
    
}
